<?php

namespace app\common\model;

use think\Model;

class User extends Model
{
    protected $name = 'user';

    // 设置字段信息
    protected $schema = [
        'id'          => 'int',
        'username'    => 'string',
        'password'    => 'string',
        'realname'    => 'string',
        'status'      => 'char',
        'note'        => 'string',
        'create_time' => 'datetime',
        'update_time' => 'datetime',
    ];

    // 设置密码
    public static function setPasswordAttr($value)
    {
        // 不可逆的密码生成器

        $value = substr(md5($value), 8, 16);
        $value = substr($value, 0, 8) . substr($value, -8);
        return md5($value);
    }

}